/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ivanbiz.menu;

import java.util.List;

/**
 *
 * @author User
 */
public class MenuServiceImpl implements MenuService{
    private MenuDAO menuDAO;

    public void setMenuDAO(MenuDAO menuDAO) {
        this.menuDAO = menuDAO;
    }

    public List getMenuByDepartement(long id) throws Exception {
        return this.menuDAO.getMenuByDepartement(id);
    }

    public boolean cekByDepartementId(long id,String url) throws Exception {
        boolean valid = false;
        Menu menu = this.menuDAO.getMenuByDeptAndUrl(id, url);
        if(menu!=null){
            return true;
        }
//        for(int x=0;x<listMenu.size();x++){
//            Menu menu = (Menu)listMenu.get(x);            
//            String replace = menu.getUrlMenu().replace("?", "#");
//            String[] path = replace.split("#");
//            System.out.println(path[0] +"       "+url.substring(1));
//            if(path[0].equals(url.substring(1))){
//               valid = true;
//               break;
//            }
//        }
       return valid;
    }

    
}
